package com.cloud.freeflow.api.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.cloud.freeflow.api.entity.ProcActFilter;
import com.cloud.freeflow.api.service.ProcFilterService;
import com.cloud.freeflow.common.result.Quokka;

@RestController
@RequestMapping("freeflow/api/procfilter")
public class ProcFilterController {

	@Autowired
	private ProcFilterService procFilterService;
	
	@RequestMapping("listactparts")
	public Quokka listActFilters(Long actDefId) {
		return new Quokka(true, procFilterService.listActFilters(actDefId));
	}
	
	@RequestMapping("listactfilter")
	public Quokka listActFilter(Long actDefId) {
		return new Quokka(true, procFilterService.listActFilter(actDefId));
	}
	
	@RequestMapping("saveactfilter")
	public Quokka saveActFilter(@RequestBody ProcActFilter filter) {
		return new Quokka(true, procFilterService.saveActFilter(filter));
	}
	
	@RequestMapping("loadactpartfilter")
	public Quokka loadActPartFilter(Long actDefId, Long partId){
		return new Quokka(true, procFilterService.loadActPartFilter(actDefId, partId));
	}
	
	
	@GetMapping("delete")
	public Quokka deleteActPartFilter(ProcActFilter filter){
		procFilterService.deleteActPartFilter(filter);
		return new Quokka(true);
	}
}
